#pragma once

#include "stdafx.h"
#include "CoMapEditBox.h"

IMPLEMENT_DYNAMIC(CoMapEditBox, CEdit)

BEGIN_MESSAGE_MAP(CoMapEditBox, CEdit)
	ON_WM_KEYDOWN()
END_MESSAGE_MAP()

CoMapEditBox::CoMapEditBox(){
}

CoMapEditBox::~CoMapEditBox(){
}

void CoMapEditBox::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags){
	switch(nChar){
		case VK_RETURN:
			this->endEdit();
			break;
	}
	CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}

void CoMapEditBox::setNodeManager(NodeManager* arg){
	this->manager = arg;
	return;
}

void CoMapEditBox::endEdit(){
	CString editText;
	this->GetWindowText(editText);
	this->manager->getCursor()->SetData(editText);

	this->ShowWindow(SW_HIDE);
	this->manager->endEditMode();

	return;
}